﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BIZ;
using DAL;

namespace SinhNhat
{
    public partial class SearchResult : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["search"] == null)
                {
                    
                }
                else
                {
                    string strSearch = Request.Params["search"];
                    lblSearch.Text = strSearch;

                    List<PRODUCT> listProduct = new ProductBIZ().Search(strSearch);
                    List<SERVICE> listService = new ServiceBIZ().Search(strSearch);
                    List<ARTICLE> listArticle = new ArticleBIZ().Search(strSearch);

                    if (listProduct.Count != 0 || listArticle.Count != 0 || listService.Count != 0)
                    {
                        rpProduct.DataSource = listProduct;
                        rpProduct.DataBind();

                        rpService.DataSource = listService;
                        rpService.DataBind();

                        rpArticle.DataSource = listArticle;
                        rpArticle.DataBind();

                        lblNoResult.Visible = false;
                    }
                    else
                    {
                        lblNoResult.Visible = true;
                    }
                }
            }
        }
    }
}